<html>

<style>
 {{{defaultstyle}}}
 body {padding: 10px 10px}
 td, th {border: solid silver 1px; padding: 5px 5px}
</style>

<h3> Creating datapacket from script</h3>

<DATAPACKET>
 <METADATA>
  <FIELDS>
  </FIELDS>
  <SCRIPT>
  { creating fields }
  for i := 1 to 10 do
  begin
    F := Fields.Add('FIELD');
    F.Attr['name'] := 'F'+inttostr(i);
    F.Attr['caption'] := 'Field '+ inttostr(i);
  end;
  { creating rows }
  for i:= 1 to 10 do
  begin
    R := RowData.Add('R');
    for k := 1 to 10 do
      R.Attr['F'+inttostr(k)] := inttostr(i)+':'+inttostr(k);
  end;
  </SCRIPT>
 </METADATA>
 <ROWDATA/>
</DATAPACKET>

<h3>Using script in report-objects</h3>

<report-objects>
<object>
<script>
 s := '<items>';
 for i := 1 to 10 do
   s := s + '<item name="item '+inttostr(i)+'"/>';
 s := s + '</items>';
 Report.RegisterVariable('items', ReleaseObject(THtXMLNode.Create(s)), true);
</script>
</object
</report-objects>

<ul>
{{#items}}
<li>{{name}}</li>
{{/items}}
</ul>
</html>
